// sort排序后比较
let arr = [1, 2, 2, 5, 8, 8, 2, 9]
function unique(arr) {
    let arr1 = arr.sort()
    for (let i = 1; i < arr1.length;) {
        if(arr1[i] == arr1[i-1]) {
            arr1.splice(i,1)
        } else i++
    }
    return arr1
}

console.log(unique(arr));